<?php

class ArticleContentTest extends BaseTest
{
    public function testInsert()
    {
        $class = new \Orm\ArticleContent\ArticleContentClass();
		$class['article_id'] = $this->testNum();
		$class['type'] = $this->testNum();
		$class['content'] = $this->testStr();
		$class['sort'] = $this->testNum();


        $class->insert();
        $result_class = new \Orm\ArticleContent\ArticleContentClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['article_id'],$result_class['article_id']);
		$this->assertEquals($class['type'],$result_class['type']);
		$this->assertEquals($class['content'],$result_class['content']);
		$this->assertEquals($class['sort'],$result_class['sort']);

        return $result_class;
    }

    /**
     * @depends testInsert
     */
    public function testUpdate($class)
    {
		$class['article_id'] = $this->testNum();
		$class['type'] = $this->testNum();
		$class['content'] = $this->testStr();
		$class['sort'] = $this->testNum();


        $class->update();
        $result_class = new \Orm\ArticleContent\ArticleContentClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['article_id'],$result_class['article_id']);
		$this->assertEquals($class['type'],$result_class['type']);
		$this->assertEquals($class['content'],$result_class['content']);
		$this->assertEquals($class['sort'],$result_class['sort']);

        return $result_class;
    }

    /**
     * @depends testUpdate
     */

    public function testDelete($class)
    {
        $class->delete($class['id']);

        $result_class = new \Orm\ArticleContent\ArticleContentClass();
        $result_class->loadById($class['id']);
        $this->assertEquals(1, $result_class['is_del']);
        return $result_class;
    }


    /**
     * @depends testInsert
     */
    public static function testClean($class)
    {
        if ($class['id']) {
            $class->realDelete($class['id']);
        }
    }
}